//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "client\fn_clientExecuteHostage.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_object","_action","_parameters","_player","_action_id","_freed_msg","_die_msg","_shared_free","_shared_alive","_free_code","_die_code","_evt_idx","_obj_act_id"];
DEFAULT_PARAM(_object,TMF_EXECUTE_ACTION_OBJECT,objNull);
DEFAULT_PARAM(_caller,TMF_EXECUTE_ACTION_CALLER,objNull);
DEFAULT_PARAM(_act_id,TMF_EXECUTE_ACTION_ID,-1);
DEFAULT_PARAM(_arguments,TMF_EXECUTE_ACTION_ARGS,[]);
DEFAULT_PARAM(_action,TMF_EXECUTE_ACTION_ACTION,[]);

_action_id = _arguments select TMF_EXECUTE_ACTION_PARAM_ACTID;

if (!isnull _object) then {
	if (_action_id > 0) then {
		_instance_id = [_object] call FFUNC(getInstanceID);
		if (count _action  <= 0) then {
			_action = [_object,_action_id] call FFUNC(actionGet);
		};
		TRACE_1("Action",_action);
		_parameters = [_action] call FFUNC(actionGetParams);
		
		if (!isnull _object) then {
			_act_id = [_object,_action,"HOSTAGE_ACTION",-1] call FFUNC(actionGetLocal);
			if (_act_id >= 0) then {
				TRACE_1("Remove Action",_act_id);
				_object removeAction _act_id;
			};
			_object setCaptive false;
			TRACE_2("Captive",_object, captive _object);
		};
	};
};
TRACE("End");
TMFPROFILERSTOP;